<?php


namespace App\Http\Admin\Controllers;

use Illuminate\Http\Request;
use App\Http\Admin\Controllers\Controller as Controller;
use Illuminate\Support\Facades\DB;
use App\Http\Authentication\UserAuthentication;

/*
 *  呼叫中心接口
 *  @author 小林《1814992057@qq.com》
 *  @datetime   2024/11/13
*/

class  HujiaoController extends Controller
{
    /**
     * 查询坐席列表
     */
    public function select_hujiao_zuoxi(){
        $res= DB::connection("mysql2")->table("hujiao_zuoxi_data")->where([
            ['time',">",date("Y-m-d",time()-60*60*24*15)." 00:00:00"],
        ])->get()->groupBy("cno")->toArray();
        $cnos=[];
        foreach($res as $k=>$v){
           $cnos[$k]=$v[count($v)-1]['loginStatus'];
        }

        return [
            'code'=>200,
            'content'=>[
                'statusData'=>$cnos
            ]
        ]; 

    }

     /**
     * 修改坐席列表
     */
    public function update_hujiao_zuoxi(Request $request){
        $data=$request->only("cno","loginStatus");
        $data['time']=date("Y-m-d H:i:s",time());
        $res= DB::connection("mysql2")->table("hujiao_zuoxi_data")->insertGetId($data);
        return [
            'code'=>200,
            'content'=>$res
        ]; 
    }


}
